﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Common;
using BYServer;
using System.Threading;

namespace ServerYuGi
{
    public class STable
    {
        public List<SPlayer> Players { get; set; }
        YServer server;
        public int ID_Table;
        public STable(YServer server)
        {
            Players = new List<SPlayer>();
            this.server = server;
        }
        public void SendMessageAll(YMSG message, params object[] param)
        {
            Console.WriteLine("Send : " + message.ToString());
            foreach (SPlayer player in Players)
            {
                player.MyConnection.AddQueueDataSend(message, param);
                Thread.Sleep(40);
            }
        }
        public void SendMessageAll(YMSG message, byte[] data) // viet them
        {

            Console.WriteLine("Send : " + message.ToString());
            foreach (SPlayer player in Players)
            {
                player.MyConnection.AddQueueDataSend(message, data);
                Thread.Sleep(40);
            }
        }
        public void SendMessageToID(int ID, YMSG message, params object[] param) // viet them
        {
            Console.WriteLine("Send : " + message.ToString());
            foreach (SPlayer player in Players)
            {
                if(player.ID == ID)
                {
                    player.MyConnection.AddQueueDataSend(message, param);
                    return;
                }
            }
               
        }
        public void SendMessageToID(int ID, YMSG message, byte[] data)
        {
            Console.WriteLine("Send : " + message.ToString());
            foreach (SPlayer player in Players)
            {
                if (player.ID == ID)
                {
                    player.MyConnection.AddQueueDataSend(message, data);
                    return;
                }
            }

        }
        
    }
}
